<div class="ajax_reg">
  <div class="title">  		
        <div class="close J_btncancel"></div>
  </div>
  
  <div class="lmain">
  
 	<div class="frombox">
			   <div class="tit">用户注册</div>
			  
	   
				<form action="" id="j_regform" method="get">
					{/*
					<if condition="C('YTATA_SMS_OPEN') eq '0'">
					<div class="ce">
				    <div class="input_text_inside t5 reginput">
	       			<div class="inputtit">输入用户名：</div>
        			<input name="username" type="text"  class="minput reginput"   maxlength="18"/>
          			</div>
</div>
					</if>
					*/}

{/* <if condition="C('YTATA_SMS_OPEN') eq '1'"> */}
	<div class="ce">
						<div class="input_text_inside t5 reginput">
						<div class="inputtit">输入手机号：</div>
						<input name="mobile" type="text"  class="minput reginput"   maxlength="11"/>
						<div class="sendbtn " id="J_send_code" style="display:none;">获取验证码</div>
						</div>
	</div>
	<div class="ce" style="display:none;">
			  <div class="input_text_inside t5 reginput">
						<div class="inputtit">手机验证码：</div>
						<input name="code" type="text"  class="minput reginput" maxlength="6"/>
						
				</div>
	</div>
{/*</if>*/}

<div class="ce">
				    <div class="input_text_inside t5 reginput">
	       			<div class="inputtit">请输入密码：</div>
        			<input name="password" type="password"  class="minput reginput"  maxlength="18"/>
          			</div>
</div>
<div class="ce">
				    <div class="input_text_inside t5 reginput">
	       			<div class="inputtit">请确认密码：</div>
        			<input name="password1" type="password"  class="minput reginput" maxlength="18"/>
          			</div>
</div>
					  
				    <div class="err"><!--错误提示 --></div>
				    <div class="ce">
				      <input class="btn" type="submit" name="Submit" id="J_doreg" value="立即注册" />
			      </div>
	    </form>
	   
			 
 	</div>
	
  </div>
  
  <div class="rmain">
	<div class="tit">使用第三方账号登录</div>
	
    <div class="api_login">
				<volist name="oauth_list" id="oauth">
			<a class="uu_api_login_btn {$key}" href="{:U('callback/index',array('mod'=>$key,'type'=>'login'))}"></a>
		</volist>
					<div class="clear"></div>
	</div>
	
	
    <div class="btnbox">
		<div class="btn_yellow btn_inline  btn_border J_user_login">有账号？直接登录</div>
	</div>
	
  </div>
  
  <div class="clear"></div>
</div>
<script type="text/javascript">
$('.J_btncancel').click(function()
{
		$(".modal,.modal_backdrop").remove();
});
//发送验证码
$("#J_send_code").die().click(function(){
					if ($(this).hasClass('btn_disabled')) return false;
					function settime(countdown) {
						if (countdown == 0) {
							$('#J_send_code').removeClass('btn_disabled');
							$('#J_send_code').text('获取验证码');
							countdown = {:C('YTATA_SMS_SETTIME')};
							return;
						} else {
							$('#J_send_code').addClass('btn_disabled');
							$('#J_send_code').text('重新发送' + countdown + '秒');
							countdown--;
						}
						setTimeout(function() {
							settime(countdown)
						},1000)
					}
					var mobile=$('#j_regform input[name=mobile]').val();
					if (mobile==''){
						disapperTooltip("remind",'请填写手机号');
						return false;
					}
					if (mobile.length!=11){
						disapperTooltip("remind",'请填写正确的手机号');
						return false;
					}
					$('#J_send_code').addClass('btn_disabled').html('正在发送...');
					$.getJSON(ajaxURL, { act:"ajax_send_mobile_code",mobile:mobile,in_user:0}, function(json){
						if (json.status==0){
							$('#J_send_code').removeClass('btn_disabled').html('获取验证码');
							disapperTooltip("remind",json.content);
						}else if (json.status==1){
							disapperTooltip("success",json.content);
							settime({:C('YTATA_SMS_SETTIME')});
						}else{
							$('#J_send_code').removeClass('btn_disabled').html('获取验证码');
							disapperTooltip("remind",json.content);
						}
					});
});
//提交注册
$("#j_regform").die().submit( function ()
{
	$("#J_doreg").val('正在注册中...').attr("disabled","disabled");
	$("#j_regform .err").hide();
	SMSopen="{:C('YTATA_SMS_OPEN')}";
	var username = $("#j_regform input[name=username]").val();
	if (username !== undefined) {
      username=$.trim(username);
	}
	mobile=$.trim($("#j_regform input[name=mobile]").val());
	code=$.trim($("#j_regform input[name=code]").val());
	password=$.trim($("#j_regform input[name=password]").val());
	password1=$.trim($("#j_regform input[name=password1]").val());
	err=$("#j_regform .err");
	var mb = /^(((13[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
	if (username !== undefined) {
	if (username==='' ){
		err.show().html('请填写用户名！');
		disapperTooltip("remind",'请填写用户名！');
		$("#J_doreg").val('立即注册').removeAttr("disabled");
		return false;
	}
	if (username.length<3 || username.length>18 ){
		$("#J_doreg").val('立即注册').removeAttr("disabled");
		err.show().html('用户名必须为3到18位字符！');
		disapperTooltip("remind",'用户名必须为3到18位字符！');
		return false;
	}
	var reg = /^[0-9]*$/;
    if(reg.test(username)) 
    {
    err.show().html('用户名不能为纯数字！');
	disapperTooltip("remind",'用户名不能为纯数字！');
	$("#J_doreg").val('立即注册').removeAttr("disabled");
  	return false;
    }
  }
	//验证手机
	if (mobile=='' && SMSopen=='1'){
		err.show().html('请填写手机号！');
		disapperTooltip("remind",'请填写手机号！');
		$("#J_doreg").val('立即注册').removeAttr("disabled");
		return false;
	}
	if(!mb.test(mobile) && SMSopen=='1') 
	{
		err.show().html('手机号填写错误！');
		disapperTooltip("remind",'手机号填写错误！');
		$("#J_doreg").val('立即注册').removeAttr("disabled");
		return false;
	}
	if (code=='' && SMSopen=='1' ){
		err.show().html('请填写手机验证码！');
		disapperTooltip("remind",'请填写手机验证码！');
		$("#J_doreg").val('立即注册').removeAttr("disabled");
		return false;
	}
	//密码验证
	if (password.length<6 || password.length>18 ){
		err.show().html('密码必须为6到18位字符！');
		disapperTooltip("remind",'密码必须为6到18位字符！');
		$("#J_doreg").val('立即注册').removeAttr("disabled");
		return false;
	}
	if (password!=password1){
		err.show().html('两次输入的密码不相同！');
		disapperTooltip("remind",'两次输入的密码不相同！');
		$("#J_doreg").val('立即注册').removeAttr("disabled");
		return false;
	}
	//开始注册
	$.getJSON(ajaxURL, { act: "ajax_user_reg_save",username:username,password:password,code:code,mobile:mobile}, function(json){
		if (json.status==0){
							disapperTooltip("remind",json.content);
							$("#J_doreg").val('立即注册').removeAttr("disabled");
							return false;
						}else if (json.status==1){
							$(".modal,.modal_backdrop").remove();
							disapperTooltip("success",json.content);					
								setTimeout(function () { 
									window.location.reload();
								}, 1800);
						}else{
							disapperTooltip("remind","未知错误");
							$("#J_doreg").val('立即注册').removeAttr("disabled");
							return false;
						}
		});
	return false;
});


</script>